# log.py
import logging


logging.basicConfig(
    filename="ch11.log",
    level=logging.DEBUG,
    format="[%(asctime)s] %(levelname)s: %(message)s",
    datefmt="%m/%d/%Y %I:%M:%S %p",
)

mylist = [1, 2, 3]
logging.info("Starting to process 'mylist'...")

for position in range(4):
    try:
        logging.debug(
            "Value at position %s is %s",
            position,
            mylist[position],
        )
    except IndexError:
        logging.exception("Faulty position: %s", position)

logging.info("Done processing 'mylist'.")
